Editing Part of a Bitmap
QuickDraw GX provides two functions that allow you to manipulate part of a bitmap. TheGXGetBitmapParts
function copies a rectangular subsection from one bitmap to a new bitmap, and theGXSetBitmapParts
function replaces a rectangular subsection of one bitmap with another bitmap.To extract part of a bitmap shape, you need to declare a reference to a new bitmap shape to hold the extracted part:
gxShape extractedBitmap;You also need to specify what part of the bitmap to extract. QuickDraw GX provides thegxLongRectangle
sturcture for this purpose:
gxLongRectangle extractedBounds = {70, 70, 125, 125};You can then use theGXGetBitmapParts
function to extract the specified section. For example, the following call extracts from the bitmap referenced by theaBitmapShape
variable the section starting at 70 pixels over and 70 pixels down and ending at 125 pixels over and 125 pixels down.
extractedBitmap = GXGetBitmapParts(aBitmapShape, &extractedBounds);Applying this function call to the bitmap shown in Figure 5-29 results in the bitmap shown in Figure 5-30.Figure 5-30 An extracted bitmap
You can use the
GXSetBitmapParts
function to replace a section of one bitmap with the contents of another bitmap.For example, you might create a small, square bitmap containing all black pixels:
gxShape insertionBitmap; gxRectangle insertionGeometry = {ff(0), ff(0), ff(100), ff(100)}; insertionBitmap = GXNewRectangle(&insertionGeometry); GXSetShapeType(insertionBitmap, gxBitmapType);Then you can insert that bitmap into the bitmap from Figure 5-29 by specifying where it should be inserted with the declaration
gxLongRectangle whereToInsert = {70, 70, 125, 125};and then inserting it with this call to theGXSetBitmapParts
function:
GXSetBitmapParts(aBitmapShape, &whereToInsert, insertionBitmap);Notice that theinsertionBitmap
shape is larger than thewhereToInsert
rectangle. QuickDraw GX only inserts as much of theinsertionBitmap
shape as fits in thewhereToInsert
rectangle, starting with the upper-left corner of theinsertionBitmap
shape.The resulting bitmap is shown in Figure 5-31.
For more information about the
GXGetBitmapParts
and theGXSetBitmapParts
functions, see page 5-74 and page 5-75, respectively.